﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Harkon.AppServer.cOne.DataAccess
{
    public class PropertyAttribute : DataAccessAttribute
    {
        public string Name { get; set; }
        public Type PropertyType { get; set; }

        public static object DefaultValue(Type type)
        {
            switch (type.FullName)
            {
                case "System.Guid":
                    return Guid.NewGuid();
                case "System.String":
                    return string.Empty;
                default:
                    return null;
            }
        }

        public override EntityProperty CreateEntityProperty()
        {
            return new EntityProperty
            {
                Name = Name,
                Value = DefaultValue(PropertyType)
            };
        }
    }
}
